#pragma once

#include "thread.hpp"
#include <vector>

namespace umtl
{
	namespace parallel
	{
		//////////////////////////////////////////////////////////////////////////
		//

		class thread_pool
		{
		public:
			typedef std::vector< thread* > Threads;

			static void push( thread*t );
			static thread * pop();
			static void push( thread**t, size_t num );
			static void pop( thread**t, size_t num );

			static short int cpu_core_num() { return instance().cpu_core_num_; }

			~thread_pool();

		private:
			Threads threads_;
			short int cpu_core_num_;
			static critical_section _ct;

			thread_pool::thread_pool();

			static thread_pool & instance() {
				static thread_pool inst;
				return inst;
			}
		};

		//////////////////////////////////////////////////////////////////////////
	}
}